package com.ikun.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import com.ikun.entity.Notices;
import com.ikun.service.NoticesService;
import com.ikun.util.Result;

import io.swagger.v3.oas.annotations.tags.Tag;

/**
 * @ClassName: NoticesController
 * @Author: 吴思伟
 * @CreateTime: 2025-03-26 10:08
 * @Description: 公告管理相关
 */
@Controller
@RequestMapping("/notices")
@Tag(name = "公告管理相关", description = "公告管理相关")
public class NoticesController {

    @Autowired
    private NoticesService noticesService;

    @GetMapping("/all")
    @ResponseBody
    public Result showAllNotices() {
        return Result.success(noticesService.findAllNotices());
    }

    @GetMapping("/content")
    @ResponseBody
    public Result showNoticesByContent(String keyWord) {
        return Result.success(noticesService.findByContent(keyWord));
    }

    @GetMapping("/list")
    @ResponseBody
    public Result showNoticesByList(Integer noticeId) {
        return Result.success(noticesService.findBylist(noticeId));
    }

    @GetMapping("/findById")
    @ResponseBody
    public Result showNoticesById(Integer userId) {
        return Result.success(noticesService.findNoticesById(userId));
    }

    @PostMapping("/publishToOwners")
    @ResponseBody
    public Result publishToOwners(@RequestBody Notices notices) {
        return Result.success(noticesService.publishToOwners(notices));
    }
}
